<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: RectangleMobility Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00187.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a>  </div>
  <div class="headertitle">
<div class="title">RectangleMobility Class Reference<div class="ingroups"><a class="el" href="a00513.html">mobility - modules handling the mobility of the hosts</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="RectangleMobility" --><!-- doxytag: inherits="MovingMobilityBase" -->
<p>Rectangle movement model. See NED file for more info.  
 <a href="a00187.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00375_source.html">RectangleMobility.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for RectangleMobility:</div>
<div class="dyncontent">
<div class="center"><img src="a00980.png" border="0" usemap="#RectangleMobility_inherit__map" alt="Inheritance graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for RectangleMobility:</div>
<div class="dyncontent">
<div class="center"><img src="a00981.png" border="0" usemap="#RectangleMobility_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a00982.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00187.html#a7042d73fe8ec8419352e5e0e8d188e28">initialize</a> (int stage)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes mobility model parameters.  <a href="#a7042d73fe8ec8419352e5e0e8d188e28"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a21250a0ded7592d849975ec6ebb41c79"></a><!-- doxytag: member="RectangleMobility::initializePosition" ref="a21250a0ded7592d849975ec6ebb41c79" args="()" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00187.html#a21250a0ded7592d849975ec6ebb41c79">initializePosition</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes the position according to the mobility model. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a32ecffdbc60f4af16a23acd84b8aab90"></a><!-- doxytag: member="RectangleMobility::move" ref="a32ecffdbc60f4af16a23acd84b8aab90" args="()" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00187.html#a32ecffdbc60f4af16a23acd84b8aab90">move</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Move the host. <br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a9310117cb7d6d7290eb16ceec3daf98f"></a><!-- doxytag: member="RectangleMobility::speed" ref="a9310117cb7d6d7290eb16ceec3daf98f" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00187.html#a9310117cb7d6d7290eb16ceec3daf98f">speed</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">speed of the host <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa83622f27b0d73d7d4f4dad3dde4d7ce"></a><!-- doxytag: member="RectangleMobility::d" ref="aa83622f27b0d73d7d4f4dad3dde4d7ce" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00187.html#aa83622f27b0d73d7d4f4dad3dde4d7ce">d</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">distance from (x1,y1), measured clockwise on the perimeter <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1cbbe28da9bb02adb85d20443b532661"></a><!-- doxytag: member="RectangleMobility::corner1" ref="a1cbbe28da9bb02adb85d20443b532661" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><b>corner1</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1b7ab4275ae23da11aaa267676966e99"></a><!-- doxytag: member="RectangleMobility::corner2" ref="a1b7ab4275ae23da11aaa267676966e99" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><b>corner2</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aff489c70c030aec6f6bcb2f25979001e"></a><!-- doxytag: member="RectangleMobility::corner3" ref="aff489c70c030aec6f6bcb2f25979001e" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><b>corner3</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="afb7594642fcbc485adf6996b73fb57c7"></a><!-- doxytag: member="RectangleMobility::corner4" ref="afb7594642fcbc485adf6996b73fb57c7" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><b>corner4</b></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Rectangle movement model. See NED file for more info. </p>
<dl class="author"><dt><b>Author:</b></dt><dd>Andras Varga </dd></dl>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a7042d73fe8ec8419352e5e0e8d188e28"></a><!-- doxytag: member="RectangleMobility::initialize" ref="a7042d73fe8ec8419352e5e0e8d188e28" args="(int stage)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void RectangleMobility::initialize </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>stage</em></td><td>)</td>
          <td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Initializes mobility model parameters. </p>
<p>If the host is not stationary it calculates a random position on the rectangle. </p>

<p>Reimplemented from <a class="el" href="a00147.html#a42b5578a418c86489c79cb765f1ffd4f">MovingMobilityBase</a>.</p>

<p>References <a class="el" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8">MobilityBase::constraintAreaMin</a>, <a class="el" href="a00187.html#aa83622f27b0d73d7d4f4dad3dde4d7ce">d</a>, <a class="el" href="a00187.html#a9310117cb7d6d7290eb16ceec3daf98f">speed</a>, and <a class="el" href="a00147.html#a6c780988c5edd64fc81a7a4d342b8118">MovingMobilityBase::stationary</a>.</p>
<div class="fragment"><pre class="fragment">{
    <a class="code" href="a00187.html#a7042d73fe8ec8419352e5e0e8d188e28" title="Initializes mobility model parameters.">MovingMobilityBase::initialize</a>(stage);
    EV &lt;&lt; <span class="stringliteral">&quot;initializing RectangleMobility stage &quot;</span> &lt;&lt; stage &lt;&lt; endl;
    <span class="keywordflow">if</span> (stage == 0)
    {
        <a class="code" href="a00187.html#a9310117cb7d6d7290eb16ceec3daf98f" title="speed of the host">speed</a> = par(<span class="stringliteral">&quot;speed&quot;</span>);
        <a class="code" href="a00147.html#a6c780988c5edd64fc81a7a4d342b8118" title="A mobility model may decide to become stationary at any time.">stationary</a> = (<a class="code" href="a00187.html#a9310117cb7d6d7290eb16ceec3daf98f" title="speed of the host">speed</a> == 0);

        <span class="comment">// calculate helper variables</span>
        <span class="keywordtype">double</span> dx = constraintAreaMax.x - <a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.x;
        <span class="keywordtype">double</span> dy = constraintAreaMax.y - <a class="code" href="a00145.html#a5b75464ca5724b99186e8577f8345ed8" title="3 dimensional position and size of the constraint area (in meters).">constraintAreaMin</a>.y;
        corner1 = dx;
        corner2 = corner1 + dy;
        corner3 = corner2 + dx;
        corner4 = corner3 + dy;

        <span class="comment">// determine start position</span>
        <span class="keywordtype">double</span> startPos = par(<span class="stringliteral">&quot;startPos&quot;</span>);
        startPos = fmod(startPos, 4);
        <span class="keywordflow">if</span> (startPos &lt; 1)
            <a class="code" href="a00187.html#aa83622f27b0d73d7d4f4dad3dde4d7ce" title="distance from (x1,y1), measured clockwise on the perimeter">d</a> = startPos * dx; <span class="comment">// top side</span>
        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (startPos &lt; 2)
            <a class="code" href="a00187.html#aa83622f27b0d73d7d4f4dad3dde4d7ce" title="distance from (x1,y1), measured clockwise on the perimeter">d</a> = corner1 + (startPos - 1) * dy; <span class="comment">// right side</span>
        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (startPos &lt; 3)
            <a class="code" href="a00187.html#aa83622f27b0d73d7d4f4dad3dde4d7ce" title="distance from (x1,y1), measured clockwise on the perimeter">d</a> = corner2 + (startPos - 2) * dx; <span class="comment">// bottom side</span>
        <span class="keywordflow">else</span>
            <a class="code" href="a00187.html#aa83622f27b0d73d7d4f4dad3dde4d7ce" title="distance from (x1,y1), measured clockwise on the perimeter">d</a> = corner3 + (startPos - 3) * dy; <span class="comment">// left side</span>
        WATCH(d);
    }
}
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/src/inet_stub/mobility/models/<a class="el" href="a00375_source.html">RectangleMobility.h</a></li>
<li>D:/Projects/MiXiM/extsrc/mixim/src/inet_stub/mobility/models/RectangleMobility.cc</li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00187.html">RectangleMobility</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:33 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
